// 专门处理roles管理

// 引入axios用户自定义模块发送请求
import axios from './common.js'

// 获取全部角色列表
export const getAllRolesList = () => {
  return axios({
    url: 'roles'
  })
}
// 添加角色
export const addNewRole = (data) => {
  return axios({
    url: 'roles',
    method: 'post',
    data
  })
}
// 删除角色
export const delRoleById = (id) => {
  return axios({
    url: `roles/${id}`,
    method: 'delete'
  })
}

// 删除指定角色的指定权限
export const delRightByRoleId = (roleId, rightId) => {
  return axios({
    url: `roles/${roleId}/rights/${rightId}`,
    method: 'delete'
  })
}
// 为角色分配权限
export const grantRightForRole = (data) => {
  return axios({
    url: `roles/${data.roleId}/rights`,
    method: 'post',
    data

  })
}
